<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./../Template/generalTemplate.xhtml">

            <ui:define name="content">

                <h:form id="form">
                    <f:view beforePhase="#{editForecastTableManagedBean.initView}">
                        <p:panel id="editForecastTableA" header="#{editForecastTableManagedBean.title}" style="height:495px;">
                            
                            <div style="margin-left: 20px;margin-right: 20px;">
                                <p:wizard showStepStatus="false"  widgetVar="wiz" style="height:450px;" flowListener="#{editForecastTableManagedBean.onFlowProcess}">
                                    <p:tab title="1" id="a">
                                        <h3>
                                            <h:outputText value="Forecast for Product A" />
                                        </h3>
                                        <p:dataTable id="forecastTableViewA" dynamic="true" emptyMessage="No Item to display" value="#{editForecastTableManagedBean.forecastTableList}" var ="ftList">
                                            <p:column>
                                                <f:facet name="header">Month</f:facet>
                                                #{ftList.monthName}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year</f:facet>
                                                #{ftList.historicalData.totalAmountA}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion Sales</f:facet>
                                                #{ftList.historicalData.promotionA}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year Base</f:facet>
                                                #{ftList.historicalData.baseAmountA}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">YoY Growth</f:facet>
                                                #{ftList.forecast.growthrateA}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Base Projection</f:facet>
                                                #{ftList.forecast.baseAmountA}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion</f:facet>
                                                <p:inplace editor="true" onEditUpdate="forecastTableViewA">
                                                    <p:inputText value="#{ftList.forecast.promotionA}" />
                                                </p:inplace>
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Sales Forecast</f:facet>
                                                #{ftList.forecast.amountA}
                                            </p:column>

                                        </p:dataTable>
                                        <br />
                                        <h:outputText value="YoY Growth Rate: " />
                                        <p:inputText value="#{editForecastTableManagedBean.growthA}"/>
                                        <p:commandButton value="Update"  update="forecastTableViewA" ajax="false" actionListener="#{editForecastTableManagedBean.updateA}" />

                                        
                                    </p:tab>

                                    <p:tab title="2" id="b">
                                        <h3>
                                            <h:outputText value="Forecast for Product B" />
                                        </h3>
                                        <p:dataTable id="forecastTableViewB" dynamic="true" emptyMessage="No Item to display" value="#{editForecastTableManagedBean.forecastTableList}" var ="ftList">
                                            <p:column>
                                                <f:facet name="header">Month</f:facet>
                                                #{ftList.monthName}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year</f:facet>
                                                #{ftList.historicalData.totalAmountB}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion Sales</f:facet>
                                                #{ftList.historicalData.promotionB}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year Base</f:facet>
                                                #{ftList.historicalData.baseAmountB}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">YoY Growth</f:facet>
                                                #{ftList.forecast.growthrateB}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Base Projection</f:facet>
                                                #{ftList.forecast.baseAmountB}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion</f:facet>
                                                <p:inplace editor="true" onEditUpdate="forecastTableViewB">
                                                    <p:inputText value="#{ftList.forecast.promotionB}" />
                                                </p:inplace>
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Sales Forecast</f:facet>
                                                #{ftList.forecast.amountB}
                                            </p:column>

                                        </p:dataTable>
                                        <br />
                                        <h:outputText value="YoY Growth Rate: " />
                                        <p:inputText value="#{editForecastTableManagedBean.growthB}"/>
                                        <p:commandButton value="Update"  update="forecastTableViewB" ajax="false" actionListener="#{editForecastTableManagedBean.updateB}" />
                                    </p:tab>
                                    
                                    <p:tab title="3" id="c">
                                        <h3>
                                            <h:outputText value="Forecast for Product C" />
                                        </h3>
                                        <p:dataTable id="forecastTableViewC" dynamic="true" emptyMessage="No Item to display" value="#{editForecastTableManagedBean.forecastTableList}" var ="ftList">
                                            <p:column>
                                                <f:facet name="header">Month</f:facet>
                                                #{ftList.monthName}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year</f:facet>
                                                #{ftList.historicalData.totalAmountC}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion Sales</f:facet>
                                                #{ftList.historicalData.promotionC}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year Base</f:facet>
                                                #{ftList.historicalData.baseAmountC}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">YoY Growth</f:facet>
                                                #{ftList.forecast.growthrateC}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Base Projection</f:facet>
                                                #{ftList.forecast.baseAmountC}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion</f:facet>
                                                <p:inplace editor="true" onEditUpdate="forecastTableViewC">
                                                    <p:inputText value="#{ftList.forecast.promotionC}" />
                                                </p:inplace>
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Sales Forecast</f:facet>
                                                #{ftList.forecast.amountC}
                                            </p:column>

                                        </p:dataTable>
                                        <br />
                                        <h:outputText value="YoY Growth Rate: " />
                                        <p:inputText value="#{editForecastTableManagedBean.growthC}"/>
                                        <p:commandButton value="Update"  update="forecastTableViewC" ajax="false" actionListener="#{editForecastTableManagedBean.updateC}" />
                                    </p:tab>
                                    
                                    <p:tab title="4" id="d">
                                        <p:growl id="growl" showDetail="true" />
                                        <h3>
                                            <h:outputText value="Forecast for Product D" />
                                        </h3>
                                        <p:dataTable id="forecastTableViewD" dynamic="true" emptyMessage="No Item to display" value="#{editForecastTableManagedBean.forecastTableList}" var ="ftList">
                                            <p:column>
                                                <f:facet name="header">Month</f:facet>
                                                #{ftList.monthName}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year</f:facet>
                                                #{ftList.historicalData.totalAmountD}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion Sales</f:facet>
                                                #{ftList.historicalData.promotionD}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Previous Year Base</f:facet>
                                                #{ftList.historicalData.baseAmountD}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">YoY Growth</f:facet>
                                                #{ftList.forecast.growthrateD}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Base Projection</f:facet>
                                                #{ftList.forecast.baseAmountD}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Promotion</f:facet>
                                                <p:inplace editor="true" onEditUpdate="forecastTableViewD">
                                                    <p:inputText value="#{ftList.forecast.promotionD}" />
                                                </p:inplace>
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Sales Forecast</f:facet>
                                                #{ftList.forecast.amountD}
                                            </p:column>

                                        </p:dataTable>
                                        <br />
                                        <h:outputText value="YoY Growth Rate: " />
                                        <p:inputText value="#{editForecastTableManagedBean.growthD}"/>
                                        <p:commandButton value="Update"  update="forecastTableViewD" ajax="false" actionListener="#{editForecastTableManagedBean.updateD}" />
                                    
                                        <p:commandButton value="Save"  update="growl" ajax="false" actionListener="#{editForecastTableManagedBean.save}" style="margin-left:550px;"/>
                                    </p:tab>

                                </p:wizard>
                            </div> 
                        </p:panel>
                    </f:view>
                </h:form>

            </ui:define>


        </ui:composition>

    </body>
</html>

